#pragma once

#include "Object/Object.h"
#include "WidgetAttribute.h"
#include <chrono>
#include "WidgetAnimationTrigger.m.h"

//use a bool control should play the animation or not 
//the animation will invoke IsActive() to determine if it should be played
RCLASS()
class WHENGINE_API RWidgetAnimationTrigger: public RObject
{
    ROBJECT

public:

    RFUNCTION()
    bool IsActive();


    RFUNCTION()
    void Activate();


    RFUNCTION()
    void Deactivate()
    {
        bIsActive=false;
    }

    //how long the actived state will last
    //if trigger is keep actived longer than this duration, trigger will be deactivated
    //if the duration is <=0, the actived state will last forever
    RFIELD()
    TWidgetAttribute<float> Duration=0.f;

protected:
    bool bIsActive=false;
    std::chrono::steady_clock::time_point StartTime; // time when the trigger is actived

};

